package org.niu.listnode;

import java.util.ArrayList;
import java.util.List;

public class IsPail {
    public boolean isPail (ListNode head) {
        // write code here
        ListNode p = head;
        List<Integer> list = new ArrayList<>();
        while(p!=null){
            list.add(p.val);
            p = p.next;
        }
        int i = 0, j = list.size()-1;
        while(i<j){
            if(!list.get(i).equals(list.get(j))) return false;
            i++;
            j--;
        }
        return true;
    }
}
